<template>
  <div>
    <Detail v-show="isAll" @close="isAll = false" :list="list" />

    <Listlist :LIST="showlist" @open="opendetail" @changeFN="changeFFN" />
  </div>
</template>

<script>
import Detail from "@/components/Detail.vue";
import Listlist from "@/components/Listlist.vue";
export default {
  components: {
    Detail,
    Listlist,
  },
  data() {
    return {
      records: [
        {
          date: "2022-01-01",
          doctor: "张三",
          diagnosis: "感冒",
          prescription: "感冒药",
        },
        {
          date: "2022-02-01",
          doctor: "李四",
          diagnosis: "头疼",
          prescription: "止疼药",
        },
        {
          date: "2022-03-01",
          doctor: "王五",
          diagnosis: "腰痛",
          prescription: "止痛贴",
        },
      ],
      isAll: false,
      list: {},
      uname: "",
    };
  },
  methods: {
    opendetail(item) {
      this.list = item;
      this.isAll = true;
    },
    changeFFN(isname) {
      if (isname) {
        this.uname = isname;
      } else {
        this.uname = "";
      }
    },
  },
  computed: {
    showlist() {
      if (!this.uname) {
        return this.records;
      } else {
        return this.records.filter((item) => item.doctor === this.uname);
      }
    },
  },
};
</script>

<style>
</style>